package com.hardson.toolkit.listcomparator;

import java.util.Date;

public class DateListComparator<T> extends ListComparator<T> {

	public DateListComparator() {

	}

	@Deprecated
	public DateListComparator(final String colName, final Class<?> clazz, final int order) {
		this.colName = colName;
		this.cl = clazz;
		this.order = order;
	}

	public DateListComparator(final String colName, final int order) {
		this.colName = colName;
		this.order = order;
	}

	@Override
	public int compare(final T t1, final T t2) {
		T swapObj[] = this.swap(t1, t2);
		Object val0 = this.getValueObj(swapObj[0]);
		Object val1 = this.getValueObj(swapObj[1]);
		Integer result = this.compareNull(val0, val1);
		if (result != null) {
			return result;
		}
		Date cmp0 = (Date) val0;
		Date cmp1 = (Date) val1;
		return cmp0.compareTo(cmp1);
	}

}